package com.learn.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class JoinPointAop {

    // 切点范围
    @Pointcut("execution(* com.learn.service..IJoinPointService+.*(..))")
    public void pointcut(){ }

    @Before("pointcut()")
    public void before1(JoinPoint jp) {
        System.out.println("---------------@Before1----------------");
        System.out.println(Arrays.toString(jp.getArgs()));
    }

    @Before("pointcut()")
    public void before2(JoinPoint.StaticPart jp) {
        System.out.println("---------------@Before2----------------");
        System.out.println(jp.getSignature());
    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("---------------@Around----------------");
        return pjp.proceed();
    }

}
